<!-- 管理员列表 -->
<template>
<div class='myadmin-userlist'>
    <top-header></top-header>
    <div class="userlist-table">
        <common-table
            :columns="columns"
            :data="adminListData"
            :total="total"
            :handle-size-change="handleSizeChange"
            :handle-current-change="handleCurrentChange"
            :page-size="pageSize"
            :current-page="currentPage">
        </common-table>
    </div>
</div>
</template>



<script>
import TopHeader from "@/components/top-header";
import {getAdminCount} from "@/api/api";
import {getAdminList } from "@/api/api";
import ComonTable from "@/components/CommonTable";

export default {

    components: {
        "top-header":TopHeader,
        "common-table": ComonTable,
    },

    data() {
        return {
            // 页面表格的数据
            adminListData:[],

            // 表格里面列的数据
            columns:[
                {
                    id:'user_name',
                    label:"姓名"
                },
                {
                    id:'create_time',
                    label:"注册时间"
                },
                {
                    id:'city',
                    label:"注册地址"
                },
                {
                    id:"admin",
                    label:"权限"
                }
            ],

            // 分页
            pageSize:5,//每页的条数
            total:0,//总的注册用户数
            currentPage:1,//默认第一页
        };
    },

    methods: {
        // 点击页码
        handleCurrentChange:function(currentPage){
            console.log(currentPage);
            this.currentPage=currentPage;
            this.getAdminListDate({
                pageNum:currentPage
            })
        },
        // 获取用户列表数据
        getAdminListDate:async function(params){
            let res=await getAdminList({
                limit:this.pageSize,
                offset:(params.pageNum-1)*this.pageSize
            })
            this.adminListData=res.data||[];
        },
        // 处理页码条数发生变化
        handleSizeChange:function(pageSize){
            this.pageSize=pageSize;
            console.log(pageSize);
            this.currentPage=1;
            this.getAdminListDate({
                pageNum:1,
            })
        }
    },

    //生命周期 - 创建完成（可以访问当前this实例）
    async created() {
        this.getAdminListDate({
            pageNum:1,
        });
        let res_total=await getAdminCount();
        this.total=res_total.count;
    },
   
}
</script>



<style lang="less" scoped>

</style>